<!doctype html>
<html>
  <head>
  <link rel="icon" 
      type="image/png" 
      href="../favicon.png">
  <title>timesheet - statistics</title>
  	<meta http-equiv="content-type" content=""text/htm; charset=UTF-8" >
	<link href="default.css" rel="stylesheet" type="text/css">
     <script type="text/javascript" src="../jquery/jquery.js"></script>
    
    
	<link href="../jquery/jquery-ui.css" rel="stylesheet" type="text/css"/>
  	<script src="../jquery/jquery-ui.min.js"></script>
  	
  	
 <link rel="stylesheet" href="../jquery-ui-1.8.4.custom.css" type="text/css" />
<link rel="stylesheet" href="../jquery/jquery.autocomplete.css" type="text/css" />
  <script type="text/javascript" src="../jquery/jquery.bgiframe.min.js"></script>
  
  <script type="text/javascript" src="../jquery/jquery.autocomplete.js"></script>  	
  	<script type="text/javascript" src="../jquery/jquery.jeditable.js"></script>
  	
  	
  	
  	
  
    <script type="text/javascript">
     
    </script>
  </head>
  <body>
  <style type="text/css">
	.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
	</style>
<script>


function showdetails(jid,uid) {
	//alert(jid+" "+uid);
	$.post("../visual/showdetails.php",{ 
  			datefrom: $('#datefrom').val(),
  			dateto: $('#dateto').val(),
  			jid: jid,
  			uid: uid
  			}, 
  		function(data){
   			$('#details').html(data);
   			
 			});
	}

function childrenlit(id) {
	//alert(id);
	$.post("../core/getchildrenid.php",{ 
  			id: id
  			}, 
  		function(data){
  			//alert(data);
   			$(data).animate({ backgroundColor: "green", opacity: 0.5 }, 0);
 			});
		
	}
function childrenunlit(id) {
	//alert(id);
	$.post("../core/getchildrenid.php",{ 
  			id: id
  			}, 
  		function(data){
  			//alert(data);
   			$(data).animate({ backgroundColor: "#808080", opacity: 1 }, 0);
 			});
		
	}

function selectanimate() {
	$(".statsok").hover(
   	function()
   	{
    		$(this).animate({ backgroundColor: "green", opacity: 0.85 }, 50);
    		childrenlit(this.id);
    		
   	},
   	function()
   	{
    		$(this).animate({ backgroundColor: "#808080", opacity: 1 }, 50);
    		childrenunlit(this.id);
   	}
  	)
}

function errordialog() {
	if ($("#info").html() != "") {
	//alert ();
	$("#info").dialog({
			modal: true,
			minWidth: 400,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	}
}

	
	

function calltree() {
	//alert('lol');
	$.post("../visual/statisticstreecaller.php", function(data){
	$('#tree_statistics').html(data);
	});
	} 

function callusers() {
	//alert('lol');
	$.post("../visual/statisticsusercaller.php", function(data){
	$('#users').html(data);
	});
	} 
 
function changestatistics(id) {
	$.post("../core/changestatistic.php",{ 
  			id: id
  			}, 
  		function(data){
   			calltree();
 			});
	}
	
function checkuncheckuser(id) {
	$.post("../core/changeuserstatistic.php",{ 
  			id: id
  			}, 
  		function(data){
   			callusers();
 			});
	}
	
	
$(document).ready(function(){
	 $('#statistics').click(function(){
	 	$.post("../core/advancedstatistics.php",{ 
  			datefrom: $('#datefrom').val(),
  			dateto: $('#dateto').val(),
  			style: $('#stl').val()
  			}, 
  		function(data){
   			$('#showstatistics').html(data);
   			selectanimate();
 			});
	 });

}); 

$(document).ready(function(){
	$('#datefrom').change(function() {
		 $('#exceldatefrom').val($('#datefrom').val());
		 });
	$('#dateto').change(function() {
		 $('#exceldateto').val($('#dateto').val());
		 });
	$('#stl').change(function() {
		 $('#excelstyle').val($('#stl').val());
		 });
  	// $('#exceldateto').val($('#dateto').val());
  	// $('#excelstyle').val($('#stl').val());
  	

}); 

 
 $(document).ready(function(){
 $("#datefrom").datepicker({ altFormat: 'yy-mm-dd' });
 $("#dateto").datepicker({ altFormat: 'yy-mm-dd' });
 calltree();
 callusers();
 
  });
 
 function detaildialog() {
	if ($("#details").html() != "") {
	//alert ();
	$("#details").dialog({
			modal: true,
			minWidth: 300,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	}
}
 
 function showdetails(jid,uid) {
	//alert(jid+" "+uid);
	//alert($('#datefrom').val());
	$.post("../visual/showdetails.php",{ 
  			datefrom: $('#datefrom').val(),
  			dateto: $('#dateto').val(),
  			jid: jid,
  			uid: uid
  			}, 
  		function(data){
   			$('#details').html(data);
   			detaildialog();
   			
 			});
	} 
	

  
</script>
<?php $loc= new loc;?>
<?php if ($_SESSION['role'] < 2) {?>	  
<div class="maindiv" id="tree_statistics"></div>
<?php } ?>	  

<div id="right2">
<div class="maindiv" id="loginfo"><p class="vertcenter"><?php echo $loc->logged_user;?>: <b><?php echo $_SESSION['username'];?> </b>
<br>
<form id="logoutform" action="index.php" method="POST">
<input type="submit" name="logout" value="log out" >
</form>
<form id="logoutform" action="index.php" method="POST">
<input type="submit" name="page" value="admin" >
</form>
</p>
</div>


<div class="maindiv" id="info"></div>	 
<div class="separator"></div>
<div class="maindiv" id="users">

</div>
<div class="separator"></div>
<div class="maindiv" id="simplestat">
<h3><?php echo $loc->selectdateforstatistics; ?></h3>
from date <input type="text" id="datefrom" value=""> 
to date<input type="text" id="dateto" value="">
style: <select name="stl" id="stl" size="1"> 
<option value="both">real and accumulated
<option value="acc">accumulated only
<option value="real">real only
</select>
<p><input type="button" id="statistics" value="<?php echo $loc->compute; ?>"</p>

<form action="../core/statistics2excel.php" method="POST">
<input type=hidden name="datefrom" id="exceldatefrom" value="">
<input type=hidden name="dateto" id="exceldateto" value="">
<input type=hidden name="style" id="excelstyle" value="both">
<p><input type="submit" value="export to excel"></p>
</form>


<div class="insider"></div>
<div class="maindiv" id="statistics"></div>
</div>
<div class="separator"></div>
<div class="maindiv" id="showstatistics">

</div>

<div class="maindiv" id="details" title="details"></div>


<?php
require '../footer.php';
//echo date('m/d/Y');
?>

</div>


</body>
</html>
